package Thread;

public class ThreadDemo7 {
    public static void main(String[] args) {
        //这个对象本身的生命周期和内核中pcb的声明周期不是一样的
        Thread thread = new Thread(()->{
            while (true){
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                   e.getStackTrace();
                }
            }
        },"寻梦缘");
        thread.setDaemon(true);
        //在start之前设置为后台线程   不能在start之后设置
        thread.start();
    }
}
